<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>商品浏览</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css" />
<script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"
	type="text/javascript" charset="utf-8"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"
	type="text/javascript" charset="utf-8"></script>
</head>
<body>
	<!-- 头部 -->
	<jsp:include page="header.jsp"></jsp:include>

	<!-- 导航搜索栏 -->
	<jsp:include page="navigation.jsp"></jsp:include>

	<div class="container-fluid">
		<h3>我的购物车</h3>
		<h4>${cartMsg}</h4>
		<table class="table table-hover">
			<thead>
				<tr>
					<th></th>
					<th>商品</th>
					<th>单价</th>
					<th>数量</th>
					<th>小计</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
			<c:forEach items="${cartItems}" var="cartItem">
				<tr>
					<td><img src="${pageContext.request.contextPath}/img/background.jpg"
						style="width: 60px; height: 60px;"></td>
					<td><a href="${pageContext.request.contextPath}/product/user-findById.do?productId=${cartItem.product.productId}">${cartItem.product.productName}&nbsp;&nbsp;${cartItem.product.productDesc}</a></td>
					<td>${cartItem.product.price}</td>
					<td>${cartItem.buyNum}</td>
					<td>${cartItem.money}</td>
					<td><button type="button" class="btn btn-danger" onclick="location.href='${pageContext.request.contextPath}/cart/delCartItem.do?cartItemId=${cartItem.cartItemId}&userId=${user.id}'">删除</button></td>
				</tr>
			</c:forEach>
				<tr>
					<td colspan="4" align="right">总金额:${cartTotal}</td>
					<td><button type="button"
							class="btn btn-danger" onclick="location.href='${pageContext.request.contextPath}/cart/clearCart.do?userId=${user.id}'">清空购物车</button></td>
					<td><button type="button" class="btn btn-primary" onclick="location.href='${pageContext.request.contextPath}/pages/user/recMessage.jsp'">去结算</button></td>
				</tr>
			</tbody>
		</table>
	</div>
</body>
</html>